Add toolbar with placed items - #51
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
.toolbar { ToolbarItem(placement:) { … } }— the first of the two "whole systems" gaps. Until now there was no way to put a button in the navigation bar at all.Why this can't use the title-sink route
navigationTitleandsearchablereach the nav chrome by recording data into the per-screenTitleSink. Toolbar items are views, so they need to be resolved as nodes. They ride instead as hidden children of the screen node — the mechanism sheets and alerts already use — each tagged with its placement, and the interpreter lifts them into the bar's slots.Placements
navigationBarLeading(sits beside the back button),navigationBarTrailing,principal(replaces the title),bottomBar(aBottomAppBar), andautomatic— which goes to the trailing side, as on iOS. A bare view in the builder is wrapped as an automatic item, so.toolbar { Button(…) }works without naming a placement.Verification
swift test— new test covering the three placements in order, the bare-view wrapping, and that a toolbar button's callback survives a re-evaluation, 75 total passing1→11→111tapping Save, Flag, and the bottom action.principalon swapped the title for the item and back, so conditionals inside the toolbar builder resolve correctly too.Scope
ToolbarItemGroup,.toolbarBackground,.toolbarRole, and toolbar item visibility/customization are not included. Toolbar items attach per navigation screen, the same scope asnavigationTitle/searchable.